﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:brightness="clr-namespace:MonitorControl;assembly=MonitorControl">

    <!--Window Buttons-->
    <Style TargetType="{x:Type Button}" x:Key="CloseBtn">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Background="#00000000" Cursor="Hand">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="_FStroke" x:Name="FStroke" Color="White"/>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="8"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="25"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="#888"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Mark" Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="4">
                            <Path.Data>
                                <GeometryGroup>
                                    <LineGeometry StartPoint="0,0" EndPoint="17,17"/>
                                    <LineGeometry StartPoint="0,17" EndPoint="17,0"/>
                                </GeometryGroup>
                            </Path.Data>
                            <Path.Effect>
                                <DropShadowEffect x:Name="BtnBlur" BlurRadius="0" ShadowDepth="0" Color="Red"/>
                            </Path.Effect>
                        </Path>
                        <Path Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="5">
                            <Path.Data>
                                <GeometryGroup>
                                    <LineGeometry StartPoint="0,0" EndPoint="17,17"/>
                                    <LineGeometry StartPoint="0,17" EndPoint="17,0"/>
                                </GeometryGroup>
                            </Path.Data>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type Button}" x:Key="RestBtn">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Background="#00000000" Cursor="Hand">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="_FStroke" x:Name="FStroke" Color="White"/>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="8"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="25"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="#888"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Mark" Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="4">
                            <Path.Data>
                                <RectangleGeometry Rect="0,0,15,15"/>
                            </Path.Data>
                            <Path.Effect>
                                <DropShadowEffect x:Name="BtnBlur" BlurRadius="0" ShadowDepth="0" Color="Yellow"/>
                            </Path.Effect>
                        </Path>
                        <Path Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="5">
                            <Path.Data>
                                <RectangleGeometry Rect="0,0,15,15"/>
                            </Path.Data>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type Button}" x:Key="MinBtn">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Background="#00000000" Cursor="Hand">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="_FStroke" x:Name="FStroke" Color="White"/>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="8"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="25"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="White"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard SpeedRatio="3">
                                        <DoubleAnimation Storyboard.TargetName="BtnBlur" Storyboard.TargetProperty="BlurRadius" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="FStroke" Storyboard.TargetProperty="Color" To="#888"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Mark" Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="4">
                            <Path.Data>
                                <LineGeometry StartPoint="0,15" EndPoint="17,15"/>
                            </Path.Data>
                            <Path.Effect>
                                <DropShadowEffect x:Name="BtnBlur" BlurRadius="0" ShadowDepth="0" Color="#00FF00"/>
                            </Path.Effect>
                        </Path>
                        <Path Stroke="{StaticResource ResourceKey=_FStroke}" StrokeThickness="5">
                            <Path.Data>
                                <LineGeometry StartPoint="0,15" EndPoint="17,15"/>
                            </Path.Data>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--Window Chrome-->
    <Style TargetType="{x:Type Window}" x:Key="DarkWindow">
        <Setter Property="MinWidth" Value="680"/>
        <Setter Property="MinHeight" Value="460"/>
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome
                    ResizeBorderThickness="8"
                    CaptionHeight="27"
                    CornerRadius="0"
                    GlassFrameThickness="0" 
                    UseAeroCaptionButtons="False"
                    NonClientFrameEdges="None"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <Border Background="Black" BorderBrush="#777" BorderThickness="1" CornerRadius="0">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="6"/>
                                <RowDefinition Height="27"/>
                                <RowDefinition/>
                                <RowDefinition Height="12"/>
                            </Grid.RowDefinitions>
                            <Border Padding="6,6,6,0" Grid.RowSpan="2" CornerRadius="0" x:Name="TitleBar">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF4E4E4E" Offset="0" />
                                        <GradientStop Color="Black" Offset="1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <Grid>
                                    <StackPanel x:Name="CaptionTitle" Orientation="Horizontal" Margin="8,0,0,0">
                                        <Button
                                            Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}"
                                            CommandParameter="{Binding ElementName=ThisMainWindow}"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                            
                                            Cursor="Arrow"
                                            x:Name="_TitleText"
                                            Margin="0,0,8,0" 
                                            HorizontalAlignment="Left" 
                                            VerticalAlignment="Center" 
                                            Style="{StaticResource BlankBtn}"
                                            Grid.Row="1" Background="#00000000">
                                            <Image Source="{TemplateBinding Icon}" MaxHeight="32" MaxWidth="32"/>
                                        </Button>
                                        <TextBlock 
                                                Text="{TemplateBinding Title}"
                                                FontSize="16"
                                                VerticalAlignment="Center"/>
                                    </StackPanel>
                                    <StackPanel x:Name="CaptionButtons" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,1,5,0">
                                        <brightness:BrightnessControl 
                                            Margin="5,0"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                            Focusable="False"/>
                                        <Button
                                            Command="{x:Static shell:SystemCommands.MinimizeWindowCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                    
                                            Focusable="False"
                                            Style="{StaticResource MinBtn}" 
                                            HorizontalContentAlignment="Center" 
                                            VerticalContentAlignment="Center"
                                            Margin="5,0"/>
                                        <Button
                                            Command="{x:Static shell:SystemCommands.MaximizeWindowCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                    
                                            Focusable="False"
                                            Style="{StaticResource RestBtn}" 
                                            HorizontalContentAlignment="Center" 
                                            VerticalContentAlignment="Center"
                                            Margin="2,0"/>
                                        <Button
                                            Command="{x:Static shell:SystemCommands.CloseWindowCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    
                                            Background="Red"
                                            Foreground="White"
                                    
                                            Focusable="False"
                                            Style="{StaticResource CloseBtn}" 
                                            HorizontalContentAlignment="Center" 
                                            VerticalContentAlignment="Center"
                                            Margin="3,0"/>
                                    </StackPanel>
                                </Grid>
                            </Border>

                            <Border Grid.Row="3" CornerRadius="0">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="Black" Offset="0" />
                                        <GradientStop Color="#FF323232" Offset="1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <ContentPresenter Grid.Row="2" Margin="10,0"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Normal">
                            <Setter TargetName="CaptionTitle" Property="Margin" Value="4,0,0,0"/>
                            <Setter TargetName="CaptionButtons" Property="Margin" Value="0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>